﻿using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using UnitTest.Mock;

using aQuery;

namespace UnitTest
{
    [TestClass]
    public class ActionReaderTests
    {
        [TestMethod]
        public void ShouldExecuteWorks()
        {
            Conta c = new Conta(100);
            c.Do(x => x.Withdraw(100)).Execute();
            Assert.AreEqual(c.Money, 0);
        }

        [TestMethod]
        public void ShouldLazyExecuteWorks()
        {
            Conta c = new Conta(0);
            PropositionReader<Conta> reader = c.Do(x => x.Withdraw(100)).If(x => x.Money > 100);
            c.Money = 1000;
            reader.Execute();
            Assert.AreEqual(c.Money, 900);
        }

        [TestMethod]
        public void ShouldIfDontWorks()
        {
            Conta c = new Conta(100);
            c.Do(x => x.Withdraw(100)).If(x => x.Money > 100).Execute();
            Assert.AreEqual(c.Money, 100);
        }

        [TestMethod]
        public void ShouldIfWorks()
        {
            Conta c = new Conta(100);
            c.Do(x => x.Withdraw(100)).If(x => x.Money == 100).Execute();
            Assert.AreEqual(c.Money, 0);
        }

        [TestMethod]
        public void ShouldWhileWorks()
        {
            Conta c = new Conta(1000);
            c.Do(x => x.Withdraw(100)).While(x => x.Money > 100).Execute();
            Assert.AreEqual(c.Money, 100);
        }

        [TestMethod]
        public void ShouldTimesWorks()
        {
            Conta c = new Conta(1000);
            c.Do(x => x.Withdraw(100)).Times(5).Execute();
            Assert.AreEqual(c.Money, 500);
        }
        
    }
}
